package com.jyniubi.oss.properties;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
@ConfigurationProperties(prefix = "aliyun.oss")
@Data
public class OssProperties implements InitializingBean {
    String endpoint;
    String accessKeyId;
    String accessKeySecret;
    String bucketName;

    public static String ENDPOINT;
    public static String ACCESSKEYID;
    public static String ACCESSKEYSECRET;
    public static String BUCKETNAME;


//    @PostConstruct
//    public void init(){
//        this.endpoint = ENDPOINT;
//        this.accessKeyId = ACCESSKEYID;
//        this.accessKeySecret = ACCESSKEYSECRET;
//        this.bucketName = BUCKETNAME;
//    }

    @Override
    public void afterPropertiesSet() throws Exception {
        ENDPOINT = this.endpoint;
        ACCESSKEYID = this.accessKeyId;
        ACCESSKEYSECRET = this.accessKeySecret;
        BUCKETNAME = this.bucketName;
    }
}
